#include <iostream>
using namespace std;

// explicit 关键字在构造函数中可禁止隐式类型的转换
//
// 不加explicit
class Point{
public:
    Point(int x, int y  = 0)
    :_x(x)
    ,_y(y)
    {
        cout << "No explicit" << endl;
    }
    
    void print(){
        cout << "_x" << _x << "_y" << _y << endl;
    }

private:
    int _x;
    int _y;
};

//添了 explicit 关键字
class Point1{
public:
    explicit
    Point1(int x, int y = 0)
    :_x(x)
    ,_y(y)
    {
        cout << "have explicit" << endl;
    }
    
    void print(){
        cout << "_x" << _x << "_y" << _y << endl;
    }
private:
    int _x;
    int _y;
};



void test(){
    Point a(1,2);
    a.print();
    Point b = 5;
    cout << "=============" << endl;
    Point1 c(1);
    c.print();
    //在 Point1 类中添加了explicit关键字就不可以使用隐式类型转换 
    //Point1 d = 4;
    //d.print();

}

int main(int atgc, char * argv[])
{
    test();
    return 0;
}

